Repository navigation
Conversation
./waf configure --use-dxvk [--dxvk-prefix=<dir>] builds the engine's real Direct3D 9 path (as on Windows) against DXVK-native instead of ToGL; DXVK translates D3D9 (including the shipped D3D9 shader bytecode) to Vulkan. The prefix (default dxvk-<arch>/) holds DXVK's headers (include/dxvk) and libdxvk_d3d9.so; only d3d9 with the SDL2 WSI is needed. - public/togl/dxvk_d3d9.h: includes DXVK's windows/d3d9/d3dx9math headers without clashing with the engine's POSIX ULONG/HMODULE typedefs. - shaderapidx9/dxvk_d3dx9.cpp: the D3DX9 helpers the shader API calls (matrix math, matrix stack, shader version); there is no d3dx9 library. - winutils: GetClientRect/IsIconic/ClientToScreen via SDL (HWND is the SDL_Window*), Sleep without the debugger break. - sdlmgr: window is created with SDL_WINDOW_VULKAN, no GL context. - shaderdevicedx8: sets DXVK_WSI_DRIVER=SDL2 unless already set. - IsPlatformOpenGL() is false with DXVK, so the Windows rendering paths (SM3 shaders, D3D9 workarounds) are taken. - imageformat.h: D3DFORMAT-based helpers are declared only where d3d9.h is included, so the rest of the engine does not see the Windows headers. - materialsystem, shaderapidx9: drop the strncpy/_snprintf poison macros for DXVK builds (they break <cstring> from DXVK's headers). - "#if POSIX" around dxabstract's AddRef/Release debug arguments is now "#if defined( DX_TO_GL_ABSTRACTION )". Timedemo (d1_canals_01, 5449 frames) on an x86_64 laptop (Intel Arc B390, Mesa ANV): 1004-1109 fps with DXVK vs 725 fps with ToGL. DXVK is added as submodule dxvk/ (doitsujin/dxvk at v3.1.1; DXVK-native is part of upstream DXVK since 2.0). It has "update = none" in .gitmodules, so the existing builds do not fetch it. scripts/build-ubuntu-amd64-dxvk.sh is like build-ubuntu-amd64.sh, but checks out the dxvk submodule, builds DXVK-native (d3d9 only, SDL2 WSI) with meson into dxvk-x86_64/ and then configures the engine with --use-dxvk. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an optional Vulkan renderer on Linux via DXVK-native, one of the items under "Current tasks" in the README.
With
./waf configure --use-dxvkthe engine compiles its real Direct3D 9 path (the one used on Windows) against DXVK's headers instead of ToGL. DXVK then translates D3D9, including the shipped D3D9 shader bytecode, to Vulkan. Without--use-dxvknothing changes: ToGL stays the default, and the Windows, macOS and Android builds are untouched.How to build
This works like
build-ubuntu-amd64.sh, but first checks out thedxvksubmodule and builds DXVK (d3d9 only, SDL2 WSI) with meson intodxvk-x86_64/. It then configures the engine with--use-dxvk. To run the game, copydxvk-x86_64/lib/libdxvk_d3d9.so*next to the engine libraries inbin/.If you build by hand, use
./waf configure --use-dxvk [--dxvk-prefix=<dir>]. The prefix defaults todxvk-<arch>/and must containinclude/dxvkandlib/libdxvk_d3d9.so.The DXVK submodule
dxvk/isdoitsujin/dxvkpinned at v3.1.1.update = nonein.gitmodules, sogit submodule updatein the existing scripts skips it. Only the DXVK script checks it out.ignore = untracked, because newer meson writessubprojects/.wraplockinto the source tree.I noticed there is also nillerusr/dxvk-native. That is Joshua Ashton's DXVK-Native at 1.9.2a (2021). Native support has been part of upstream DXVK since 2.0, so I used upstream v3.1.1. If you prefer your own fork as the submodule, it would need to be updated to a 2.x/3.x release, and switching the URL is easy.
Engine changes
public/togl/dxvk_d3d9.h(new): includes DXVK'swindows.h,d3d9.h,d3dx9math.handd3dx9shader.h. DXVK'sULONG(32-bit) andHMODULEare renamed while including, because the engine's POSIX typedefs differ.ID3DXBufferis declared by hand, because the fulld3dx9.hneeds GDI types that DXVK does not have.shaderapidx9/dxvk_d3dx9.cpp(new): the D3DX9 helpers the shader API calls, because there is no d3dx9 library on Linux. These are matrix math,ID3DXMatrixStackandD3DXGetShaderVersion.D3DXCompileShaderreturnsE_NOTIMPL.GetVidMemBytes()returns 2 GB, because D3D9 cannot tell.winutils:GetClientRect,IsIconicandClientToScreenare implemented with SDL (HWNDis theSDL_Window*).Sleep,GetCurrentThreadandSetThreadAffinityMaskare shared with ToGL. TheDebuggerBreak()stays only for ToGL, because the D3D9 path really calls these functions.sdlmgr: the window is created withSDL_WINDOW_VULKANand no GL context.sys_mainwind: the D3D9 device window is the SDL window.shaderdevicedx8: setsDXVK_WSI_DRIVER=SDL2unless it is already set. DXVK-native throws an error without it.platform.h:IsPlatformOpenGL()isfalsewith DXVK, so the Windows rendering paths are used (SM3 shaders, D3D9 vendor workarounds).imageformat.h: on POSIX this defines a fakeD3DFORMATenum with ToGL values. With DXVK the real enum is used, and theD3DFORMAThelpers are declared only wheredxvk_d3d9.his included. This keeps the Windows headers out of the rest of the engine.materialsystem,shaderapidx9wscripts: thestrncpyand_snprintfpoison defines are dropped for DXVK builds. They break<cstring>from DXVK's headers (using ::strncpy).dxabstract: theAddRef/Releasedebug arguments now depend on#if defined( DX_TO_GL_ABSTRACTION )instead of#if POSIX.wscript: the--use-dxvkand--dxvk-prefixoptions.toglis not built with DXVK.Testing
timedemoon ad1_canals_01demo (5449 frames, 1280×720), release builds:d1_canals_01render the same as with ToGL.scripts/build-ubuntu-amd64-dxvk.shbuilds from a fresh clone.I did not add a CI job. The existing amd64 job runs on Ubuntu 20.04, whose meson and gcc are probably too old for DXVK 3.x. A DXVK job would have to run on
ubuntu-latest. I can add one if you want it.How this was made
I made this together with Claude Code, Anthropic's AI coding assistant. I guided it throughout and corrected it where needed, so that the change fits the existing project structure:
scripts/build-ubuntu-*.shwinutils)I tested the result myself on both machines listed above.